package com.lc.hot100.lc121;

public class Main {
	public static void main(String[] args) {
		
	}
}

class Solution {
    public int maxProfit(int[] prices) {
        
    	int min = prices[0];
    	int n = prices.length;
    	int res = 0;
    	for (int i = 1; i < n; i ++) {
    		res = Math.max(res, prices[i] - min);
    		min = Math.min(min, prices[i]);
    	}
    	return res;
    }
}
